﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows;

namespace D3StatsClient.ViewModel
{
    public class ProcessPickerWindowViewModel : ViewModelBase
    {

        public ProcessPickerWindowViewModel()
        {
            Processes = new ObservableCollection<Process>();

            foreach (Process p in Process.GetProcessesByName("Diablo III"))
            {
                Processes.Add(p);
            }
        }

        public bool IsItemSelected
        {
            get { return (bool)GetValue(IsItemSelectedProperty); }
            set { SetValue(IsItemSelectedProperty, value); }
        }

        // Using a DependencyProperty as the backing store for IsItemSelected.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty IsItemSelectedProperty = 
            DependencyProperty.Register("IsItemSelected", typeof(bool), typeof(ProcessPickerWindowViewModel), new PropertyMetadata(false));



        public Process SelectedItem
        {
            get { return (Process)GetValue(SelectedItemProperty); }
            set { SetValue(SelectedItemProperty, value); }
        }

        // Using a DependencyProperty as the backing store for SelectedItem.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty SelectedItemProperty =
            DependencyProperty.Register("SelectedItem", typeof(Process), typeof(ProcessPickerWindowViewModel), new PropertyMetadata(null,new PropertyChangedCallback((a,v)=> ((ProcessPickerWindowViewModel)a).IsItemSelected = true)));

        

        public ObservableCollection<Process> Processes
        {
            get { return (ObservableCollection<Process>)GetValue(ProcessesProperty); }
            set { SetValue(ProcessesProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Processes.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ProcessesProperty =
            DependencyProperty.Register("Processes", typeof(ObservableCollection<Process>), typeof(ProcessPickerWindowViewModel), new PropertyMetadata(null));

        
    }
}
